package orfeu.engine;



import orfeu.engine.R;


import AI.Hero;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class AddHighscore extends Activity
{
	EditText ed;
	DatabaseHelper bs;
	ImageView enter;
	TextView tv;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	     setContentView(R.layout.newhighscore);
	     tv=new TextView(this);
	     tv=(TextView)findViewById(R.id.textView3);
	     tv.setText(Float.toString(Hero.getHero().HIGHSCORE));
	     enter=new ImageView(this);
	     enter=(ImageView)findViewById(R.id.imageView1);
	     ed = new EditText(this);
         ed = (EditText)findViewById(R.id.editText1);
	     bs = new DatabaseHelper(this);;
	     enter.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String user = ed.getText().toString();
				String score =tv.getText().toString();
				int score2=Integer.parseInt(score);
				System.out.println("Hello");
				 try{
	    				bs.createDataBase();
	    				bs.openDataBase();
	    				bs.insertHighscore(user,score2);
	    				bs.close();
	    				
		    	    }
				 catch(Exception e)
		    	    {
					// Toast.makeText(this, e.toString(), Toast.LENGTH_LONG);
		    	Toast toast=Toast.makeText(getApplicationContext(),"abcd"+ e.toString(),Toast.LENGTH_LONG);
		    	toast.show();
		    	//ed.setText(e.toString());
	    			}
				finish();
				
			}
		});
	     
	}
	
	

}
